<?php
/**
 * 管理后台-群组管理控制器-RCenter
 * 用于控制群组显示页面、群组增删改操作
 * @author Pony
 */
class group extends spController{
	function __construct(){
		if($_SESSION['ucid'] != RC_ADMIN){$this->error('您不是RCenter管理员',spUrl('main','login'));}
		parent::__construct();
	}
	
	function index(){
		if($_SESSION['ucid'] != RC_ADMIN){$this->error('您不是RCenter管理员',spUrl('main','login'));}
		$lib = spClass('lib_group');
		$this -> grouplist = $lib -> getGroups();
		$this -> tpl_img = TPL_IMG;
		$this -> display('admin_group.htm');
	}
	
	function add(){
		$lib = spClass('lib_group');
		if($lib -> addGroup($this->spArgs('groupname'),$this->spArgs('redirecturl',' ')) > 0){
			$this -> success('已成功添加一个群组',spUrl('group'));
		}
		else{
			$this -> error('系统出现错误：添加群组失败',spUrl('group'));
		}
	}
	
	function delete(){
		$lib = spClass('lib_group');
		$deletes_wait = $this->spArgs('delete');
		while ($foo = each($deletes_wait)){
			$lib -> deleteGroup($foo['value']);
		}
		$this->success('已从RCenter中删除选定群组',spUrl('group'));
	}
	
	function edit_page(){
		$lib = spClass('lib_group');
		$this -> groupinfo = $lib -> getGroups($this->spArgs('groupid'));
		$this -> tpl_img = TPL_IMG;
		$this -> display('admin_group_edit.htm');
	}
	
	function edit(){
		$lib = spClass('lib_group');
		if($lib -> editGroup($this->spArgs('groupid'),$this->spArgs('groupname'),$this->spArgs('redirecturl',' ')) >0){
			$this -> success('已成功更改',spUrl('group','edit_page',array('groupid'=>$this->spArgs('groupid'))));
		}
		else{
			$this -> error('更改失败或无任何变化',spUrl('group','edit_page',array('groupid'=>$this->spArgs('groupid'))));
		}
	}
}